package com.zhang.learn.controller;


import com.zhang.learn.common.BaseResponse;
import com.zhang.learn.common.ResultUtils;
import com.zhang.learn.service.strategy.kpi.KpiCalculatorFactory;
import com.zhang.learn.service.strategy.kpi.KpiCalculatorStrategy;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/kpi")
@Slf4j
public class KPIController {

    @PostMapping("/computed")
    public BaseResponse<String> computedKPI(String dateStr,Integer type) {
        KpiCalculatorStrategy kpiCalculatorStrategy = KpiCalculatorFactory.getKpiCalculatorStrategy(type);
        kpiCalculatorStrategy.computedKPI(dateStr);

        return ResultUtils.success("1");
    }

}
